package com.bj58.mis.apm.server.kylin.controller;

import com.bj58.mis.apm.server.kylin.service.IKylinAnalysisService;
import com.bj58.mis.apm.server.kylin.service.IKylinDataService;
import com.bj58.mis.apm.server.kylin.service.IZipFileService;
import com.bj58.mis.apm.server.kylin.util.JsonUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@Controller
@RequestMapping("/kylin")
public class KylinAnalysisController {

    Log log = LogFactory.getLog(KylinAnalysisController.class);

    @Resource
    private IKylinDataService kylinDataService;

    @ResponseBody
    @RequestMapping("/data/receive")
    public String receive(HttpServletRequest req){
        String dataType = req.getParameter("datatype");
        String jsonData = req.getParameter("jsondata");
        try{
            kylinDataService.save(dataType, jsonData);
        }catch (Exception e){
            e.printStackTrace();
            return "0";
        }
        return "1";
    }

    @ResponseBody
    @RequestMapping("/data/time")
    public String getServerUpTime(){

        return null;
    }
}
